/**
 * File:   DHTFrame.java
 * Author: Gvennet
 */
package scenarios.gui;

import scenarios.gui.tabs.DataTab;
import scenarios.gui.tabs.NodeTab;
import scenarios.net.NetNodeModel;
import scenarios.net.TestNode;

import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.concurrent.ScheduledThreadPoolExecutor;

/**
 * todo write javadoc
 */
public final class NetFrame
{

	private NetFrame()
	{
	}

	public static JFrame createFrame(String title,
									 ArrayList<TestNode> nodes,
									 NetNodeModel nodeModel,
									 ScheduledThreadPoolExecutor scheduledExecutor,
									 NetDataTableModel localDataTableModel)
	{
		JFrame frame = new JFrame(title);

		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		JTabbedPane tabbedPane = new JTabbedPane();

		tabbedPane.add("Узлы", NodeTab.createNodesTab(nodeModel, nodes, scheduledExecutor));
		tabbedPane.add("Данные", DataTab.createLocalDataTab(localDataTableModel, nodes, scheduledExecutor));

		frame.add(tabbedPane);

		frame.getRootPane().setPreferredSize(new Dimension(720, 480));

		frame.pack();

		frame.setLocationByPlatform(true);
		frame.setVisible(true);


		return frame;
	}
}